<template>
    <div>
        <!--顶部滑动条区域-->
        <div id="slider" class="mui-slide">
            <div id="sliderSeqmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a v-for="item in categorys" :class="['mui-control-item',item.id==0?'mui-active':'']" @tap="getImages(item.id)">
                        {{item.title}}
                    </a>
                </div>
            </div>
            <ul class="photo-list">
                <router-link v-for="item in imglist" :to="'/home/photoinfo/'+item.id" tag="li">
                    <img v-lazy="item.img_url">
                    <div class="info">
                        <h2 class="title">{{item.title}}</h2>
                        <p class="info-body white-space">{{item.zhaiyao}}</p>
                    </div>
                </router-link>
            </ul>
        </div>
    </div>
</template>
<script>
    /*导入mui的js文件*/
    import mui from '../../../lib/mui/js/mui.min';
    import connector from '../../base/interface.js';

    export default {
        data(){
            return{
                categorys:[],
                /*图片列表*/
                imglist:[]
            }
        },methods:{
            getAllCategory(){
                /*获取所有的分类*/
                connector.getAllCategory().then(result=>{
                    var obj={id:0,title:"全部"};
                    this.categorys=result;
                    this.categorys.unshift(obj);
                },err=>{
                    console.log(err.message);
                });
            }, getImages(id=0){
                /*获取图片列表数据*/
                connector.getImages(id).then(result=>{
                    this.imglist=result;
                },err=>{
                    console.log(err.message);
                });
            }
        },created() {
            this.getAllCategory();
            this.getImages();
        },mounted() {
            /*初始化滑动控件*/
            mui('.mui-scroll-wrapper').scroll({
                //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
                deceleration: 0.0005
            });
        }
    }
</script>

<style lang="scss" scoped>
@import "../../base/baseRem.scss";
.photo-list{
    padding: remFu(5);
    margin: 0;
    li{
        list-style: none;
        text-align: center;
        box-shadow: 0 0 6px #999;
        position: relative;
    }
    img[lazy='loading']{
        width: 40px;
        height: 300px;
        margin: auto;
    }
    .info{
        color: white;
        position: absolute;
        bottom: remFu(5);
        left: 0;
        right: 0;
        background-color: rgba(0,0,0,0.5);
        max-height: remFu(100);
        overflow: hidden;
        .title{
            font-size: 14px;
            text-align: left;
        }
        .info-body{
            color: white;
            font-size: 13px;
            text-align: left;
            margin: 0;
        }
    }
}

</style>